package com.googlecode.spruce.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "service_group")
public class ServiceGroup implements Serializable
{

    /** Serial ID */
    private static final long serialVersionUID = -7756334955511658787L;

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "name")
    private String name;

    @OneToMany(mappedBy = "serviceGroup")
    private Set<Service> service;

    @OneToMany(mappedBy = "serviceGroup")
    private Set<ServiceGroupSchedule> serviceGroupSchedules;

    public Integer getId()
    {
        return id;
    }

    public void setId(final Integer id)
    {
        this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(final String name)
    {
        this.name = name;
    }

    /**
     * @return the service
     */
    public Set<Service> getService()
    {
        return service;
    }

    /**
     * @param service
     *            the service to set
     */
    public void setService(final Set<Service> service)
    {
        this.service = service;
    }

    /**
     * @return the serviceGroupSchedules
     */
    public Set<ServiceGroupSchedule> getServiceGroupSchedules()
    {
        return serviceGroupSchedules;
    }

    /**
     * @param serviceGroupSchedules
     *            the serviceGroupSchedules to set
     */
    public void setServiceGroupSchedules(final Set<ServiceGroupSchedule> serviceGroupSchedules)
    {
        this.serviceGroupSchedules = serviceGroupSchedules;
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        return (name == null) ? 0 : name.hashCode();
    }

    /**
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(final Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        ServiceGroup other = (ServiceGroup) obj;
        if (name == null)
        {
            if (other.name != null)
            {
                return false;
            }
        }
        else if (!name.equals(other.name))
        {
            return false;
        }
        return true;
    }

}
